home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS19.ADF / Progs / WinSize / WinSize.c < prev    next >
C/C++ Source or Header  |  1989-01-27  |  3KB  |  102 lines

  1. /*************************************************************************
  2.  *
  3.  *    WinSize - a window sizing utility
  4.  *
  5.  *    Copyright ⌐ 1987 by
  6.  *        Limited Reality, Inc.
  7.  *
  8.  ************************************************************************/
  9.  
  10. #include        <exec/types.h>
  11. #include        <intuition/intuitionbase.h>
  12. #include    <stdio.h>
  13.  
  14. #ifdef stdout
  15. #undef stdout
  16. #endif
  17.  
  18. FILE *stdout;
  19.  
  20. struct IntuitionBase *IntuitionBase = 0;
  21.  
  22. main(argc, argv)
  23. int argc;
  24. char *argv[];
  25. {
  26.     int width = 9999, height = 9999, left = -1, top = -1;
  27.  
  28.     stdout = (FILE *)Output();
  29.  
  30.     if ((argc == 2) && (argv[1][0] == '?')) {
  31.     printf("Usage: %s [leftedge topedge width height]\n",argv[0]);
  32.     exit(0);
  33.     }
  34.  
  35.     if ((argc != 1) && (argc != 5)) {
  36.     puts("Bad ARGS");
  37.     exit(0);
  38.     }
  39.  
  40.     if ((IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 0)) == 0) {
  41.         exit(20);
  42.     }
  43.  
  44.     if (argc == 5) {
  45.     left = atoi(argv[1]);
  46.     top = atoi(argv[2]);
  47.     width = atoi(argv[3]);
  48.     height = atoi(argv[4]);
  49.     }
  50.  
  51.     if (width > IntuitionBase->ActiveScreen->Width)
  52.     width = IntuitionBase->ActiveScreen->Width;
  53.  
  54.     if (width > IntuitionBase->ActiveWindow->MaxWidth)
  55.     IntuitionBase->ActiveWindow->MaxWidth = width;
  56.  
  57.     if (width < IntuitionBase->ActiveWindow->MinWidth)
  58.     width = IntuitionBase->ActiveWindow->MinWidth;
  59.  
  60.     if (height > IntuitionBase->ActiveScreen->Height)
  61.     height = IntuitionBase->ActiveScreen->Height;
  62.  
  63.     if (height > IntuitionBase->ActiveWindow->MaxHeight)
  64.     IntuitionBase->ActiveWindow->MaxHeight = height;
  65.  
  66.     if (height < IntuitionBase->ActiveWindow->MinHeight)
  67.     height = IntuitionBase->ActiveWindow->MinHeight;
  68.  
  69.     if (left < 0) left = 0;
  70.  
  71.     if (top < 0) top = 0;
  72.  
  73.     if (left > (IntuitionBase->ActiveScreen->Width - width))
  74.     left = (IntuitionBase->ActiveScreen->Width - width);
  75.  
  76.     if (top > (IntuitionBase->ActiveScreen->Height - height))
  77.     top = (IntuitionBase->ActiveScreen->Height - height);
  78.  
  79.     if ((left < IntuitionBase->ActiveWindow->LeftEdge) ||
  80.     (top < IntuitionBase->ActiveWindow->TopEdge)) {
  81.         MoveWindow(IntuitionBase->ActiveWindow,
  82.         left-IntuitionBase->ActiveWindow->LeftEdge,
  83.         top-IntuitionBase->ActiveWindow->TopEdge);
  84.  
  85.         SizeWindow(IntuitionBase->ActiveWindow,
  86.         width-IntuitionBase->ActiveWindow->Width,
  87.         height-IntuitionBase->ActiveWindow->Height);
  88.     } else {
  89.         SizeWindow(IntuitionBase->ActiveWindow,
  90.         width-IntuitionBase->ActiveWindow->Width,
  91.         height-IntuitionBase->ActiveWindow->Height);
  92.  
  93.         MoveWindow(IntuitionBase->ActiveWindow,
  94.         left-IntuitionBase->ActiveWindow->LeftEdge,
  95.         top-IntuitionBase->ActiveWindow->TopEdge);
  96.     }
  97.  
  98.     RethinkDisplay();
  99.  
  100.     CloseLibrary(IntuitionBase);
  101. }
  102.